<?php
	$dir = pathinfo($_SERVER['SCRIPT_FILENAME']); 

	if (ini_set("include_path",ini_get("include_path").((strtoupper(PHP_OS) == "LINUX") ? ":" : ";").$dir['dirname']) === false) {
		echo "ERROR: Definicion en el include_path";
		exit;
	}
	
	
	include('../adodb/adodb.inc.php');
	include_once('../adodb/adodb-pager.inc.php');
    include_once('../conf/dbconn_param.php');
	
	$db = ADONewConnection($dbdriver);
	$db->Connect($server, $user, $password, $database);
	$db->SetFetchMode(ADODB_FETCH_ASSOC);

  $id = $_REQUEST['id'] ;
  $value = $_REQUEST['value'] ;
  $column = $_REQUEST['columnName'] ;
  $columnPosition = $_REQUEST['columnPosition'] ;
  $columnId = $_REQUEST['columnId'] ;
  $rowId = $_REQUEST['rowId'] ;
  
  switch ($column) {
		case 'Activo' : $column = 'activo'; break;
		
		
		default: $column = strtolower($column);
	}

	//echo "update bodega set $column = '$value' where bodega_id = $id ";
	//Always accepts update(return posted value)
	$sql = "update producto set $column = '$value' where producto_id = $id ";
	$rs = $db->Execute($sql);
		
	$f = fopen("updating.txt", "w");
    fwrite($f, "$id $value $column $columnPosition $columnId $rowId");
    fclose($f);
	
	echo trim(utf8_encode($value));

	// Si el value es diferente entonces hay un error en la actualizacion
	//echo $value;
	//echo "El valor $value es incorrecto";
?>